package yangsw87.basic;

public class CH04_S_Q2 {

	public static void main(String[] args) {

		Rectangle r = new Rectangle();
		Rectangle s = new Rectangle(1, 1, 2, 3);

		r.show();
		s.show();
		System.out.println(s.square());
		r.set(-2, 2, -1, 4);
		r.show();
		System.out.println(r.square());
		if (r.equals(s))
			System.out.println("두 사각형은 같습니다.");
	}

}

class Rectangle {
	int x1;
	int y1;
	int x2;
	int y2;
	int square;

	public Rectangle() {
	}

	public Rectangle(int x1, int y1, int x2, int y2) {
		this.x1 = x1;
		this.y1 = y1;
		this.x2 = x2;
		this.y2 = y2;
	}

	void set(int x1, int y1, int x2, int y2) {
		this.x1 = x1;
		this.y1 = y1;
		this.x2 = x2;
		this.y2 = y2;
	}

	int square() {
		square = (x2 - x1) * (y2 - y1);
		return square;
	}

	void show() {
		System.out.println(x1 + "," + y1);
		System.out.println(x2 + "," + y2);

	}

	boolean equals(Rectangle r) {
		if (square == r.square) {
			return true;
		} else
			return false;
	}

}
